GDataManager    	= Packages.it.softphone.commons.gdata.GDataManager;
gdata           	= Packages.com.google.gdata.data;
ApplicationConfig   = Packages.it.softphone.spring.ApplicationConfig;


function main( ui ) {	

	var manager = GDataManager.createInstance( "TEST_REPORT", "http", "docs.google.com");

	manager.login(
			"bartolomeo.sorrentino@gmail.com", 
			"BactiuG00GLE"
			);
	
	var sc = ApplicationConfig.getServletContext();
	
	var path = sc.getRealPath( "/");

	println( "=====> " + path );
	
	var rpt = new java.io.File( path, "Template-Badge.xls");

	println( "=====> " + rpt.name );
	
	var s = manager.service;
	
	println( "=====> " + s );
	
	manager.service.setConnectTimeout( 30*1000 );
	manager.service.setReadTimeout( 30*1000 );
	
	var ref = manager.uploadDocument(rpt, "First Report in cloud 7th attempt", null);

	println( "=====> " + ref );
	
	if( ref!=null ) {

		var url = new java.net.URL(ref.getAclFeedLink().getHref());
		manager.addShareReader( url, new java.net.URI("user:vincenzo.tandurella@gmail.com"));
		manager.addShareReader( url, new java.net.URI("user:casolla.alessandro@gmail.com"));
	}
		
	return ref.getDocumentLink();
}
